<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.add"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.add"/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first" /></a></li>
            <li class="active"><a href="#"><spring:message code="message.title.xiTongSheZhi" /></a></li>
             <li class="active"><a href="#"><spring:message code="message.title.yongHuGuanLi" /></a></li>
            <li class="active"><a href="#"><spring:message code="message.title.center_zhuyonghu" /></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">
                    <div class="form-group form-group-xs">
                        <label for="searchPharCode"><spring:message code='message.lable.weiShengJuBianMa'/>：</label>
                        <input class="form-control" type="text" id="heaBurCode" placeholder="<spring:message code='message.lable.weiShengJuBianMa'/>" maxlength="18" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="searchPharName"><spring:message code='message.lable.weiShengJuMingCheng'/>：</label>
                        <input class="form-control" type="text" id="heaBurName" placeholder="<spring:message code='message.lable.weiShengJuMingCheng'/>" maxlength="200" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="searchPharName"><spring:message code='message.lable.suoShuDiQu'/>：</label>
                        <select id="area1" class="form-control" style="width:100px;display:inline-block;"></select>
                        <select id="area2" class="form-control" style="width:100px;display:inline-block;"></select>
                        <select id="area3" class="form-control" style="width:100px;display:inline-block;"><option value=""><spring:message code="message.select.option"></spring:message> </option></select>
                    </div>
                    <button type="button" class="btn btn-success btn-sm" onclick="search();"><spring:message code='message.button.seach'/></button>
                </div>
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
          <div class=" box box-warning bottongroup">
      		  <a href="${ctx}/sysUser/zxUserList.html" class="btn btn-default btn-sm"><spring:message code='message.button.getBack'/></a>
    	</div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
    function generateAccount(name,id,userType){
	    	$.HN.dialog.open({
	             id:id,
	             title:"<spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.add"/>",
	             url:"${ctx}/sysUser/toGenerateAccount.html?id="+id+"&userType="+userType+"&name="+name,
	             width:"300px",
	             height:"185px",
	             closefunc:function(){
	            	 search();
	             }
	         });
	}
  
    	function search(page) {
    		var heaBurCode = $("#heaBurCode").val();
    		var heaBurName = $("#heaBurName").val();
    		var area1 = $("#area1").val();
    		var area2 = $("#area2").val();
    		var area3 = $("#area3").val();
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{"heaBurCode":heaBurCode, "heaBurName":heaBurName, "area1":area1, "area2":area2, "area3":area3},
    	        page : (page || 1)
    	    }).trigger("reloadGrid"); //重新载入  
    	}
    
        $(function () {
        	 $('.form-inline :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(0).focus();
            $("#gridlist").jqGrid({
                url: "${ctx}/sysUser/getHeaBurList.html",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 270,
                colNames: [
					'<spring:message code='message.jqGrid.cz'/>',
					'<spring:message code='message.lable.weiShengJuBianMa'/>', 
					'<spring:message code='message.lable.weiShengJuMingCheng'/>', 
					'<spring:message code='message.lable.suoShuDiQu'/>',
					'<spring:message code='message.lable.lianXiRen'/>', 
					'<spring:message code='message.lable.phone'/>'
                ],
                colModel: [
                    { name: 'operate', width: 5, align:"center", sortable: false,
                    	formatter : function(val, opts, rowdata) {
                    		var str="";
                    		str += "<a href='javascript:generateAccount(\""+rowdata.heaBurName+"\",\""+rowdata.heaBurId+"\",${userType});' ><spring:message code='message.lable.shengChengZhangHao'/></a>";
	                    	return str;
                  		}
                    },
                    { name: 'heaBurCode', width: 10, align:"center", sortable: false},
                    { name: 'heaBurName', width: 15, align:"left", sortable: false },
                    { name: 'arFullname', width: 10, align:"center", sortable: false},
                    { name: 'contactName', width: 10, align:"center", sortable: false},
                    { name: 'contactTelephone', width: 10, align:"center", sortable: false}
                ],
                rowNum: 20,
                rowList: [10, 20, 30],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
                caption: "<spring:message code='message.lable.weiShengJuLieBiao'/>",
                gridComplete:function(){
                    autoRNWidth("gridlist");
                },
                jsonReader: {
                    id: "hospId"
                }
            });
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            
  		  $("#area1").HNSelect({
	            url: "${pageContext.request.contextPath}/selectController/getArea.html", 
	            data: { ID: '000000' },  
	            defaultText: "<option value=''><spring:message code='message.select.option'/></option>",
	            func: function () {
	                 $("#area2").HNSelect({
	                    parent_selector: "#area1", 
	                    url: "${pageContext.request.contextPath}/selectController/getArea.html", 
	                    dataid: "ID",
	                    defaultText: "<option value=''><spring:message code='message.select.option'/></option>",
	                    		  func: function () {
	                                  $("#area3").HNSelect({
	                                      parent_selector: "#area2", 
	                                      url: "${pageContext.request.contextPath}/selectController/getArea.html", 
	                                      dataid: "ID", 
	                                      defaultText: "<option value=''><spring:message code='message.select.option'/></option>"
	                                  });
	                              }
	                }); 
	            }
	        });
        });
    </script>
</body>
</html>
